package com.example.ioc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;

@Configuration
//@Import(MyImportBeanDefinitionRegistrar.class)
public class SpringConfig {

    @Bean
    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(){
        return new PropertySourcesPlaceholderConfigurer();
    }

    /*@Bean
//    @Primary // 指定为主要 bean
    public UserService userService(UserDao userDao){
        UserServiceImpl userService = new UserServiceImpl();
        userService.setUserDao(userDao);
        return userService;
    }*/

    /*@Bean
    public UserService userService(UserDao userDao, UserDao2 userDao2){
        return new UserServiceImpl(userDao, userDao2);
    }*/

    /*@Bean
    public UserService userService(){
        System.out.println("使用@Bean声明UserService 1");
        UserDao userDao = userDao();
        System.out.println("使用@Bean声明UserService 2");
        return new UserServiceImpl(userDao);
    }

    @Bean
    public UserDao userDao(){
        System.out.println("使用@Bean声明userDao");
        return new UserDaoImpl();
    }*/

}
